<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/28
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html >
    <head>
        <title>Title</title>
        <!--引入layui样式文件-->
        <link rel="stylesheet" href="layui/css/layui.css">
    </head>
    <body>

    <div class="layui-form-item">
        <label class="layui-form-label">房间号</label>
        <div class="layui-input-block">
            <input type="text" id="roomNum"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="text" id="type"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="text" id="state"   class="layui-input" value="1"
                   style="width: 200px;" disabled="disabled">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">楼层</label>
        <div class="layui-input-block">
            <input type="text" id="floorNum"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间价格</label>
        <div class="layui-input-block">
            <input type="text" id="roomPrice"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">折后价</label>
        <div class="layui-input-block">
            <input type="text" id="discountPrice"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">普通会员价</label>
        <div class="layui-input-block">
            <input type="text" id="omPrice"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">vip会员价</label>
        <div class="layui-input-block">
            <input type="text" id="vipPrice"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>
    <button class="layui-btn layui-btn-normal"
            style="margin-left: 200px;" onclick="save()">保存</button>
    </body>
    <script src="layui/layui.js"></script>

    <script>
        var $;
        layui.use(['jquery'],function(){
            $ = layui.jquery;

        });

        function save(){
            if($("#roomNum").val()==''||$("#roomNum").val()==null){
                alert("房间号不能为空");
                return;
            }
            if($("#type").val()==''||$("#type").val()==null){
                alert("类型不能为空");
                return;
            }
            if($("#floorNum").val()==''||$("#floorNum").val()==null){
                alert("楼层号不能为空");
                return;
            }
            if($("#roomPrice").val()==''||$("#roomPrice").val()==null){
                alert("类型不能为空");
                return;
            }
            if($("#discountPrice").val()==''||$("#discountPrice").val()==null){
                alert("类型不能为空");
                return;
            }
            if($("#omPrice").val()==''||$("#omPrice").val()==null){
                alert("类型不能为空");
                return;
            }
            if($("#vipPrice").val()==''||$("#vipPrice").val()==null){
                alert("类型不能为空");
                return;
            }
            $.ajax({
                url:"getRoomByRoomNum",
                type:"post",
                data:{roomNum:$("#roomNum").val()},
                dataType:"json",
                success:function (param){
                    if(param.code>0){
                        alert("该房间号已存在，请更换");
                        return;
                    }
                }
            })
            var index = parent.layer.getFrameIndex(window.name);
            window.parent.addRoom($("#roomNum").val(),$("#type").val(),$("#state").val(),$("#floorNum").val(),$("#roomPrice").val(),$("#discountPrice").val(),$("#omPrice").val(),$("#vipPrice").val());
            parent.layer.close(index);
        }
    </script>
</html>